import { RouteRecordRaw } from 'vue-router';

/**
 * 建议：路由 path 路径与文件夹名称相同，找文件可浏览器地址找，方便定位文件位置
 *
 * 路由meta对象参数说明
 * meta: {
 *      title:           菜单栏及 tagsView 栏、菜单搜索名称（国际化）
 *      isLink：         是否超链接菜单，开启外链条件，`1、isLink: 链接地址不为空 2、isIframe:false`
 *      isHide：         是否隐藏此路由
 *      isKeepAlive：    是否缓存组件状态
 *      isAffix：        是否固定在 tagsView 栏上
 *      isIframe：       是否内嵌窗口，开启条件，`1、isIframe:true 2、isLink：链接地址不为空`
 *      roles：          当前路由权限标识，取角色管理。控制路由显示、隐藏。超级管理员：admin 普通角色：common
 *      icon：           菜单、tagsView 图标，阿里：加 `iconfont xxx`，fontawesome：加 `fa xxx`
 *      hideBreadcrumb： 否隐藏当前路由面包屑
 *      breadcrumbKey：  面包屑key
 * }
 */

/**
 * 定义动态路由
 * 前端添加路由，请在顶级节点的 `children 数组` 里添加
 * @returns 返回路由菜单数据
 */
export const dynamicRoutes: RouteRecordRaw[] = [
  {
    path: '/',
    name: '布局',
    redirect: '/home',
    component: () => import('@/layout/index.vue'),
    meta: {
      hideBreadcrumb: true,
    },
    children: [
      {
        path: '/home',
        name: '首页',
        component: () => import('@/pages/Home/index.vue'),
        meta: {
          icon: 'HomeFilled',
          title: 'Home',
          roles: ['home'],
          hideBreadcrumb: true,
        },
      },
      {
        path: '/model',
        name: '模型管理',
        redirect: '/model/manage',
        meta: {
          icon: 'WalletFilled',
          title: 'model',
          roles: ['model_management'],
        },
        children: [
          {
            path: '/model/manage',
            name: '管理模型',
            component: () => import('@/pages/Model/index.vue'),
            meta: {
              icon: 'HomeFilled',
              title: 'model',
              roles: ['model_management'],
            },
          },
          {
            path: '/model/manage/list',
            name: '模型列表',
            component: () => import('@/layout/components/main.vue'),
            redirect: '/model/manage/database',
            meta: {
              icon: 'HomeFilled',
              title: 'model',
              roles: ['model_management:model_management'],
              isHide: true,
              breadcrumbKey: 'modelName',
            },
            children: [
              {
                path: '/model/manage/database',
                name: '模型数据',
                component: () => import('@/pages/Model/database/index.vue'),
                meta: {
                  icon: 'HomeFilled',
                  title: 'model',
                  roles: ['model_management:model_management'],
                  isHide: true,
                  breadcrumbKey: 'modelName',
                },
              },
              {
                path: '/model/manage/database/data-list',
                name: '数据信息',
                component: () =>
                  import('@/pages/Model/database/datalist/index.vue'),
                meta: {
                  icon: 'HomeFilled',
                  title: 'model',
                  roles: ['model_management:model_management'],
                  isHide: true,
                  breadcrumbKey: 'dataSetName',
                },
              },
            ],
          },
          {
            path: '/model/manage/tag',
            name: '标签管理',
            component: () => import('@/pages/Model/tag/index.vue'),
            meta: {
              icon: 'HomeFilled',
              title: 'model',
              roles: ['model_management:model_management'],
              isHide: true,
              breadcrumbKey: 'modelName',
            },
          },
        ],
      },
      {
        path: '/mark',
        name: '标注管理',
        redirect: '/mark/manage',
        meta: {
          icon: 'List',
          title: 'mark',
          roles: ['marking_management'],
        },
        children: [
          {
            path: '/mark/manage',
            name: '任务管理',
            component: () => import('@/pages/Task/manage/index.vue'),
            meta: {
              icon: 'HomeFilled',
              title: 'model',
              roles: ['marking_management:task_management'],
            },
          },
          {
            path: '/mark/list',
            name: '详情信息',
            component: () => import('@/layout/components/main.vue'),
            redirect: '/mark/task/list',
            meta: {
              icon: 'HomeFilled',
              title: 'model',
              roles: ['marking_management:task_managemen'],
              isHide: true,
              hideBreadcrumb: true,
            },
            children: [
              {
                path: '/mark/task/list',
                name: '任务信息',
                component: () => import('@/layout/components/main.vue'),
                redirect: '/mark/task/detail',
                meta: {
                  icon: 'HomeFilled',
                  title: 'model',
                  roles: ['marking_management:task_managemen'],
                  isHide: true,
                  breadcrumbKey: 'taskName',
                },
                children: [
                  {
                    path: '/mark/task/detail',
                    name: '任务详情',
                    component: () =>
                      import('@/pages/Task/manage/detail/index.vue'),
                    meta: {
                      icon: 'HomeFilled',
                      title: 'model',
                      roles: ['marking_management:task_managemen'],
                      isHide: true,
                      hideBreadcrumb: true,
                    },
                  },
                  {
                    path: '/mark/task/detail/data-list',
                    name: '数据管理',
                    component: () =>
                      import('@/pages/Task/manage/detail/datalist/index.vue'),
                    meta: {
                      icon: 'HomeFilled',
                      title: 'model',
                      roles: ['marking_management:task_managemen'],
                      isHide: true,
                      breadcrumbKey: 'taskId',
                    },
                  },
                ],
              },
            ],
          },
          {
            path: '/mark/my-task',
            name: '我的任务',
            component: () => import('@/pages/Task/myTask/index.vue'),
            meta: {
              icon: 'HomeFilled',
              title: 'model',
              roles: ['marking_management:my_tasks'],
            },
          },
          {
            path: '/mark/check',
            name: '标注审核',
            component: () => import('@/pages/Task/check/index.vue'),
            meta: {
              icon: 'HomeFilled',
              title: 'model',
              roles: ['marking_management:marking_review'],
              breadcrumbKey: 'name',
            },
          },
        ],
      },
      {
        path: '/system',
        name: '系统管理',
        redirect: '/system/user',
        meta: {
          icon: 'Platform',
          title: 'model',
          roles: ['system'],
        },
        children: [
          {
            path: '/system/user',
            name: '用户管理',
            component: () => import('@/pages/User/index.vue'),
            meta: {
              icon: 'UserFilled',
              title: 'model',
              roles: ['system:user_management'],
            },
          },
          {
            path: '/system/role',
            name: '角色管理',
            component: () => import('@/pages/Role/index.vue'),
            meta: {
              icon: 'HomeFilled',
              title: 'model',
              roles: ['system:role_management'],
            },
          },
        ],
      },
    ],
  },
];

/**
 * @description 定义静态路由（默认路由）
 * @returns 返回路由菜单数据
 */
export const staticRoutes = [
  {
    path: '/login',
    name: '登录',
    component: () => import('@/pages/Login/index.vue'),
  },
  {
    path: '/sign',
    name: '标注详情页',
    component: () => import('@/pages/Sign/index.vue'),
  },
];

/**
 * 定义404、401界面
 */
export const notFoundAndNoPower = [
  {
    path: '/:path(.*)*',
    name: 'notFound',
    component: () => import('@/pages/Error/index.vue'),
    meta: {
      title: 'message.staticRoutes.notFound',
      isHide: true,
    },
  },
];
